package richbar.com.richbar.help;

import android.content.Context;
import android.os.CountDownTimer;
import android.support.v4.content.ContextCompat;
import android.widget.TextView;

import richbar.com.richbar.R;


/**
 * Created by QiYang on 2018/10/16.
 */

public class CountDownTimerHelp extends CountDownTimer {
    private TextView textView;
    private Context context;
    public CountDownTimerHelp(Context context, TextView textView, long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
        this.textView = textView;
        this.context = context;
    }

    @Override
    public void onTick(long l) {
        textView.setTextColor(ContextCompat.getColor(context, R.color.gray9));
        textView.setClickable(false);
        textView.setText("重新发送（" + l / 1000 + "）");
    }

    @Override
    public void onFinish() {
        textView.setClickable(true);
        textView.setTextColor(ContextCompat.getColor(context, R.color.red));
        textView.setText("获取验证码");
    }
}
